package com.gitee.mars.vaccin.controller;


import com.gitee.mars.vaccin.request.UserRequest;
import com.gitee.mars.vaccin.response.result.R;
import com.gitee.mars.vaccin.service.IUserService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * User 控制层
 *
 * @Author wq
 * @Date 2021-03-16
 **/
@RestController
@RequestMapping("/user")
@AllArgsConstructor
public class UserController {

    private final IUserService userService;


    /**
     * 登录
     *
     * @param request request
     * @return R
     */
    @PostMapping("/login")
    private R login(@RequestBody UserRequest request) {
        return R.success(userService.login(request));
    }

    /**
     * 注册
     *
     * @param request request
     * @return R
     */
    @PostMapping("/register")
    private R register(@RequestBody UserRequest request) {
        return R.success(userService.register(request));
    }


}